﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XCSerialPort
{
    public interface ISerialPortManager
    {
        /// <summary>
        /// 设备状态
        /// </summary>
        /// <returns></returns>
        bool DeviceStatus();
        /// <summary>
        /// 打开串口。
        /// </summary>
        bool Open(out string msg);

        /// <summary>
        /// 关闭串口。
        /// </summary>
        void Close(out string msg);
        /// <summary>
        /// 读写寄存器
        /// </summary>
        /// <param name="addr">地址</param>
        /// <returns></returns>
        List<ulong> ReadRegister(ulong addr, out string msg, int length = 1, int timeoutMilliseconds = 150);
        /// <summary>
        /// 写寄存器
        /// </summary>
        /// <param name="addr">地址</param>
        /// <param name="value">值</param>
        void WriteRegister(ulong addr, List<ulong> value, out string msg, int length = 1, int timeoutMilliseconds = 150);
        /// <summary>
        /// 获取可用的串口列表及其属性。
        /// </summary>
        /// <returns>一个包含串口属性的字符串数组的列表。</returns>
        string[] GetSerialPorts(out string msg);
        /// <summary>
        ///设置选择设备索引
        /// </summary>
        /// <param name="_Index"></param>
        void SetDeviceConfig(int _Index = 0 , uint _deviceID = 0);
    }
}
